<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:c="livcos.org/ns/cosmos"
	xmlns:f="livcos.org/ns/xslt/function"
	exclude-result-prefixes="c f">

  <xsl:import href="doc/document.xsl" />
  <xsl:import href="admin/community.xsl" />
  <xsl:import href="bm/forecast.xsl" />
  <xsl:import href="pm/usecase.xsl" />
  <xsl:import href="model.xsl" />

  <xsl:param name="ref"/>
  
  <xsl:variable name="dataUri" select="f:find-data-object($ref)"/>
  
  <xsl:template match="/" mode="default">
		<xsl:choose>
			<xsl:when test="$dataUri != ''">
				<xsl:apply-templates select="doc($dataUri)/*"/>
			</xsl:when>
			<xsl:when test="normalize-space($ref) != ''">
				<xsl:message terminate="yes"><xsl:value-of select="$ref"/> not found!</xsl:message>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="*"/>
			</xsl:otherwise>
		</xsl:choose>
  </xsl:template>

  <xsl:template match="/" mode="doc-info">
  	<xsl:choose>
  		<xsl:when test="$dataUri != ''">
  			<xsl:apply-templates select="doc($dataUri)/*" mode="doc-info"/>
  		</xsl:when>
  		<xsl:otherwise>
  			<xsl:apply-templates select="*" mode="doc-info"/>
  		</xsl:otherwise>
  	</xsl:choose>
  </xsl:template>
	
</xsl:stylesheet>
